<template>
  <div>
    <div v-if="detailType">
      <el-table :header-cell-style="{ background: '#F3F8FE' }" align="center" :data="tableData" border
        class="tableHeight">
        <el-table-column align="center" prop="ccto" label="裁决文书">
        </el-table-column>
        <el-table-column align="center" prop="cdn" label="案件号">
        </el-table-column>
        <el-table-column align="center" width="120" label="操作" v-if="!table">
          <template slot-scope="scope">
            <el-button class="see" @click="see(scope.row.cid)" type="text">查看</el-button>
            <el-button class="see" @click="openUrl(scope.row.cid)" type="text">下载</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination background @current-change="handleCurrentChange" :current-page="page" :page-size="limit"
          layout="total, prev, pager, next, jumper" :total="Number(count)" align="left"></el-pagination>
      </div>
    </div>

    <div v-else>
      <div v-if="data" class="content">
        <el-button @click="back" size="mini" type="danger">返回</el-button>
        <p v-html="data" style="margin-top:10px"></p>
      </div>
      <div v-else>
        <el-empty description="暂无信息"></el-empty>
      </div>
    </div>
  </div>
</template>

<script>
import Visitpatent from './Visitpatent.vue'
import { detail } from "@/api/newuser"

import {
  Iitigation,
  iitigationDownload,
} from "@/api/user"
import {
  litigationlist,
} from "@/api/newuser"
export default {
  data() {
    return {
      detailType: true,
      id: this.$route.query.id,
      // id: 1,//测试
      activeName: 'patent',
      tableData: [],
      index: 0,
      page: 1,
      limit: 10,
      count: 0,
      data: "",
    }
  },
  watch: {
    'form_admin.company': {
      handler(newV, oldV) {
        this.litigationlist()
      },
      deep: true
    }
  },
  props: {
    form_admin: {
      type: Object,
      default: () => ({})
    },
    table: {
      type: Boolean,
      default: false
    },
    table: {
      type: Boolean,
      default: false
    },
  },
  components: { Visitpatent },
  mounted() {
    this.litigationlist()
  },
  methods: {
    back() {
      this.detailType = true
      this.data = ''
    },
    litigationlist() {
      litigationlist({
        company: this.form_admin.company,
        page: this.page,
        limit: this.limit,
      }).then(res => {
        this.tableData = res.list
        this.count = res.count
      })
    },

    //点击第几页
    async handleCurrentChange(currentPage) {
      this.page = currentPage
      try {
        const res = await litigationlist({
          id: this.id,
          page: this.page,
          limit: this.limit,
        })
      } catch (e) {
        this.$message.error(e.message);
      }
    },
    async see(cid) {
      // this.$router.push({ path: "/workVisit/details", query: { id: cid } });
      this.detailType = false
      try {
      const res = await detail({ cid: cid });
      this.data = res.html
    } catch (e) {
      this.$message.error(e.message);
    }

    },
    async openUrl(id) {
      try {
        const res = await iitigationDownload({
          cid: id,
        });
        window.open(res.pdf);
      } catch (error) {
        this.$message.error(error.message);
      }
    },
  },
};
</script>

<style scoped lang="less">
::v-deep .el-drawer__header {
  margin-bottom: 20px;
  display: none;
}

.pagination {
  margin: 10px auto;
}

::v-deep .card_v .el-card__body {
  min-height: 1050px;
  padding: 0;

  .el-tabs .el-tabs__content {
    padding: 0 20px;

    tr th {
      font-size: 16px;
    }

    tr td {
      font-size: 16px;
    }
  }
}

.trademark {
  padding: 12px 0;

  .logo {}

  ._text {
    height: 105px;

    .el-row {
      height: 100%;
      display: flex;
      justify-content: space-between;
      flex-direction: column;

      .title_t {
        display: flex;
        justify-content: space-between;

      }

      .title_b {
        font-size: 12px;
      }
    }

  }
}

// ::v-deep .v_tabs .el-tabs__header .el-tabs__nav .el-tabs__item {
//   padding: 0 20px !important;
// }



@media (max-width: 1360px) {}

@media (max-width: 1280px) {}

@media (max-width: 768px) {}
</style>
